class LogReader
	def initialize(f)
		puts "new LogReader #{f}"
		@file = File.new(f) 
		count = 0
		@iplist = []
		@scanlist = []

		while (!@file.eof and count < 1000)  do
			count+=1
			line = @file.gets
			scan = execLine line 
			puts "#{count}\t#{scan.length}\n #{line}" if scan.length != 1
			s = scan.length>0 ? scan[0]:[]
			@scanlist.push s
			@iplist.push s[0]
		end
		
		uniqip = @iplist.uniq
		puts "total #{@iplist.length}, uniq ip #{uniqip.length}"
		
		ipcount = []
		uniqip.each do |ip|
			line = ip 
			c = @iplist.count line
			puts "#{line} [#{c}]" if c > 1
			ipcount.push c
		end
		ipcount.sort!{|x,y| y <=> x}

		puts ipcount.join("\t")
		puts @scanlist.length
		high = @scanlist.each do |item|
			puts item[0]
			return item[0] == "113.89.206.234"
		end
		
		@scanlist.each do |item|
			puts 1
			puts item
		end
		high.each do |item|
			puts high[3]
		end
			
	end
	
	#on line
	def execLine(line)
		s = line.scan /^(\S*) (\S*) (\S*) \[(.*)\] \"(.*)\" (\S*) (\S*) \"(.*)\" \"(.*)\"/
		return s
	end

	def getIP

	end

	def getTime

	end
end
#puts ARGV.length
#LogReader.new(ARGV[0])
LogReader.new(ARGV[0])
puts "done"
